import collections
class Solution(object):
    def countPairs(self, deliciousness):
        total = [1 << i for i in range(22)]
        d = collections.Counter(deliciousness)
        ans = 0
        for t in total:
            for key in d:
                left = t - key
                if left == key:
                    ans += d[key] * (d[key] - 1)
                else:
                    if left in d:
                        print(key, left)
                        ans += d[key] * d[left]

        return (ans // 2) % (10 ** 9 + 7)

data = Solution()
d1 = [149,107,1,63,0,1,6867,1325,5611,2581,39,89,46,18,12,20,22,234]
print(data.countPairs(d1))